<?php 
class ControllerModuleNewsFeed extends Controller {  

	public function index() { 
	
		// Load language 
		$this->language->load('module/newsfeed');
		
		$this->data['text_latest_news'] = $this->language->get('text_latest_news');
		
		// Load model
		$this->load->model('catalog/newsfeed');
		
		$this->data['latest_news'] = $this->model_catalog_newsfeed->getRandomNewsItem();
		
		// Set the module id
		$this->id = 'newsfeed';
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/module/newsfeed.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/module/newsfeed.tpl';
		} else {
			$this->template = 'default/template/module/newsfeed.tpl';
		}
			
		$this->render();
	}
	
	public function randomNews() {
	
		// Load model
		$this->load->model('catalog/newsfeed');		
		
		// Get a random news item
		$latest_news = $this->model_catalog_newsfeed->getRandomNewsItem();		
		
		// Send to client
		$this->response->setOutput($latest_news);	
	}
  	
}
?>